From 1180fc801a2bd8b3b883e04a38a5a4534fd2101d Mon Sep 17 00:00:00 2001 From: robertlipe Date: Tue, 30 Sep 2014 17:38:36 +0000 Subject: [PATCH] White B. Coot contributes f90g support. --- gpsbabel/Makefile.in | 2 +- gpsbabel/f90g_track.cc | 158 +++++++++++++++++++++++++++++++ gpsbabel/vecs.cc | 8 ++ gpsbabel/xmldoc/formats/f90g.xml | 19 ++++ 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 gpsbabel/f90g_track.cc create mode 100644 gpsbabel/xmldoc/formats/f90g.xml diff --git a/gpsbabel/Makefile.in b/gpsbabel/Makefile.in index 8c6c643a3..55d6ef118 100644 --- a/gpsbabel/Makefile.in +++ b/gpsbabel/Makefile.in @@ -80,7 +80,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o \ pocketfms_bc.o pocketfms_fp.o pocketfms_wp.o naviguide.o enigma.o \ vpl.o teletype.o jogmap.o bushnell.o bushnell_trl.o wintec_tes.o \ subrip.o garmin_xt.o garmin_fit.o lowranceusr4.o \ - mtk_locus.o googledir.o mapbar_track.o mapfactor.o energympro.o + mtk_locus.o googledir.o mapbar_track.o f90g_track.o mapfactor.o energympro.o FMTS=@FMTS@ diff --git a/gpsbabel/f90g_track.cc b/gpsbabel/f90g_track.cc new file mode 100644 index 000000000..e858e057a --- /dev/null +++ b/gpsbabel/f90g_track.cc @@ -0,0 +1,158 @@ +/* + Map file reader for F90G Automobile DVR. + + Copyright (C) 2014 Jim Keeler, James.L.Keeler@gmail.com + Copyright (C) 2001-2013 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + Read the map file contents picking out the defined record types. + + The map file contains a constant 30 byte header record followed by a variable number of + TT records. The TT records start with the two characters "TT" and are 251 bytes long. + The TT records conatain values for time, position and velocity. + + */ + +#include "defs.h" +#include + +#define MYNAME "f90g_track" +#define TTRECORDSIZE 249 +#define HEADERRECORDSIZE 30 +#define FLIPEDBITS 0xaa + + + +static gbfile* fin = NULL; +static route_head* track = NULL; + + +static +arglist_t f90g_track_args[] = { + ARG_TERMINATOR +}; + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ +#define VALIDHEADER "MEDIA 1." +static void +f90g_track_rd_init(const char* fname) +{ + char header[HEADERRECORDSIZE]; + + fin = gbfopen(fname, "r", MYNAME); + gbfseek(fin, 0, SEEK_SET); + if (gbfread(header, 1, HEADERRECORDSIZE, fin) != HEADERRECORDSIZE) { + fatal(MYNAME ": read error"); + } else { + // flip bits and check for valid header + for (int i = 0; irte_name = QString::fromLatin1(fname); + track_add_head(track); + } +} + +static void +f90g_track_rd_deinit(void) +{ + gbfclose(fin); +} + +// needed conversion factors +static const double MIN_PER_DEGREE = 600000.0f; +static const float SPEED_CONVERSION = (10.0f)/(36.0f); // convert KPH to meters per second + +static void +f90g_track_read(void) +{ + Waypoint* readWaypoint; + char northSouth, eastWest, velocityMark, ttRec[TTRECORDSIZE], tempBuf[20]; + int year, mon, mday, hour, min, sec, latitudeDeg, latitudeMin, longitudeDeg, longitudeMin, velocity; + QDateTime dt; + + is_fatal((track == NULL), MYNAME "Track setup error"); + for (;;) { + if ((gbfread((void*)ttRec, 1, 2, fin) != 2) + || (memcmp(ttRec,"TT",2))) { + break; + } + if (gbfread((void*)ttRec, 1, TTRECORDSIZE, fin) != TTRECORDSIZE) { + break; + } + for (int i = 0; iSetCreationTime(dt); + readWaypoint->latitude = (double(latitudeDeg) + double(latitudeMin)/MIN_PER_DEGREE) + * ((northSouth == 'N')? 1.0f : -1.0f); + readWaypoint->longitude = (double(longitudeDeg) + double(longitudeMin)/MIN_PER_DEGREE) + * ((eastWest == 'E')? 1.0f : -1.0f); +// qDebug() << dt.toString() << latitudeDeg << latitudeMin << readWaypoint->latitude; + readWaypoint->speed = float(velocity) * SPEED_CONVERSION; + // Name the Waypoint + snprintf(tempBuf, sizeof(tempBuf), "T%2.2d%2.2d-%3.3dKPH", min, sec, velocity); + readWaypoint->shortname = QString(tempBuf); + + // Add the Waypoint to the current track + track_add_wpt(track, readWaypoint); + } + } +} + +// capabilities below means: we can only read trace file. + +ff_vecs_t f90g_track_vecs = { + ff_type_file, + { ff_cap_none, (ff_cap)(ff_cap_read), ff_cap_none }, + f90g_track_rd_init, + NULL, + f90g_track_rd_deinit, + NULL, + f90g_track_read, + NULL, + NULL, + f90g_track_args, + CET_CHARSET_UTF8, 0 /* ascii is the expected character set */ + /* not fixed, can be changed through command line parameter */ +}; diff --git a/gpsbabel/vecs.cc b/gpsbabel/vecs.cc index 764c2797b..90c6f5442 100644 --- a/gpsbabel/vecs.cc +++ b/gpsbabel/vecs.cc @@ -176,6 +176,7 @@ extern ff_vecs_t subrip_vecs; extern ff_vecs_t format_garmin_xt_vecs; extern ff_vecs_t format_fit_vecs; extern ff_vecs_t mapbar_track_vecs; +extern ff_vecs_t f90g_track_vecs; extern ff_vecs_t mapfactor_vecs; static @@ -1062,6 +1063,13 @@ vecs_t vec_list[] = { "trk", NULL, }, + { + &f90g_track_vecs, + "f90g", + "F90G Automobile DVR GPS log file", + "map", + NULL, + }, { &mapfactor_vecs, "mapfactor", diff --git a/gpsbabel/xmldoc/formats/f90g.xml b/gpsbabel/xmldoc/formats/f90g.xml new file mode 100644 index 000000000..07e13baf1 --- /dev/null +++ b/gpsbabel/xmldoc/formats/f90g.xml @@ -0,0 +1,19 @@ + + +This format is for the .map files produced by the F90G automobile +Digital Video Recorder (DVR) when recording videos. The files are +found on the sd card in /DCIM/DCIMA/NORMAL/ and are named with a time +stamp and the .map extension. This format records each track point's +latitude, longitude, local time, GMT time and velocity in Kilometers +Per Hour. The local time is used in the gpsbabel translation. +Minutes, seconds and the velocity are combined to form each track point's +name in the converted trace. + + +This was implemented by analyzing data from a F90G DVR supplied from China. +Firmware F20-2013121217-E + + +The format was tested only using .map samples collected in the USA. We are +interested in samples or test results from other hemispheres. + -- 2.30.2